package mysql

import (
	"gorm.io/gorm"
)

type Goods struct {
	gorm.Model
	GoodsId int `gorm:"type:int(11);not null;index:ip_idx"`
	UserId  int `gorm:"type:int(11);not null;"`
	Num     int `gorm:"type:int(11);not null;"`
	Stock   int `gorm:"type:int(11);not null;"`
}

type Cart struct {
	gorm.Model
	GoodsId int `gorm:"type:int(11);not null;index:ip_idx"`
	UserId  int `gorm:"type:int(11);not null;"`
	Num     int `gorm:"type:int(11);not null;"`
	Price   int `gorm:"type:int(11);not null;"`
}

func (g *Goods) GoodsFind(GoodsId int) error {
	return DB.Debug().Where("goods_id = ?", GoodsId).Limit(1).Find(&g).Error
}
